<?php
/* Copyright [2014] UW-Parkside
 * Authors: Matthew Zygowicz, Armando Narvaez
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

/**
 *This model controls the logic involved with manipulating HelpScreen
 *and the helpscreen table.  Any operation involving the helpscreen should
 *be done in this class.
 */
class Helpscreen extends CI_Model {

    /**
     *Load the database from the config file, and register this function
     *as a valid codeigniter model
     */
    public function __construct() {
        $this->load->database();
        parent::__construct();
    }
    
    /**
     *This function retrieves the information section
     *from the helpscreen table
     *
     *@return string returns the information string
     */
    public function getInformation(){
        $sql = 'SELECT information FROM helpscreen;';
        $query = $this->db->query($sql);
        $result = $query->result_array();
        return $result[0]['information'];
    }
    
    /**
     *This function retrieves the scanning section
     *from the helpscreen table
     *
     *@return string returns the scanning string
     */
    public function getScanning(){
        $sql = 'SELECT scanning FROM helpscreen;';
        $query = $this->db->query($sql);
        $result = $query->result_array();
        return $result[0]['scanning'];
    }
    
    /**
     *This function retrieves the routing section
     *from the helpscreen table
     *
     *@return string returns the routing string
     */
    public function getRouting(){
        $sql = 'SELECT routing FROM helpscreen;';
        $query = $this->db->query($sql);
        $result = $query->result_array();
        return $result[0]['routing'];
    }
    
    /**
     *This function sets the information record of the helpscreen table
     *
     *@param string $information the string to be inserted into information
     */
    public function setInformation($information){
        $sql = 'UPDATE helpscreen SET `information`=?';
        $query = $this->db->query($sql,array(strip_tags($information)));
    }
    
    /**
     *This function sets the routing record of the helpscreen table
     *
     *@param string $routing the string to be inserted into routing
     */
    public function setRouting($routing){
        $sql = 'UPDATE helpscreen SET `routing`=?';
        $query = $this->db->query($sql,array(strip_tags($routing)));
    }
    
    /**
     *This function sets the scanning record of the helpscreen table
     *
     *@param string $scanning the string to be inserted into scanning
     */
    public function setScanning($scanning){
        $sql = 'UPDATE helpscreen SET `scanning`=?';
        $query = $this->db->query($sql,array(strip_tags($scanning)));
    }

}

?>